package com.qczl.pme.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 机顶盒（会议室）信息表
 * 
 * @author SongR
 * 
 */
@Entity
@Table(name="pme_basis_stb")
public class PMESTB implements Serializable {

	private static final long serialVersionUID = 7043535616964454495L;
	
	private Long id;//编号
	private String no;//机顶盒mac
	private String name;//名称
	private String desc;//描述
	private Integer status;//状态(-1、已删除 0、可用 1、不可用)
	private Date creattime;//创建时间
	private Long sort;//排序
	private Long userid;//用户编号
	
	private Long cameraid;//对应摄像头
	
	private PMEArea area;//一个机顶盒有一个区域
	private Set<PMECamera> cameras;//绑定的摄像头
	private Set<PMEDuties> duties;//可以使用的职务
	private Set<PMETopic> topics;//可以使用的主题
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "stb_id")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	@Column(name = "stb_no")
	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}
	@Column(name = "stb_name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "stb_desc")
	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}
	@Column(name = "stb_status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
	@Column(name = "stb_creattime")
	public Date getCreattime() {
		return creattime;
	}

	public void setCreattime(Date creattime) {
		this.creattime = creattime;
	}
	@Column(name = "stb_sort")
	public Long getSort() {
		return sort;
	}

	public void setSort(Long sort) {
		this.sort = sort;
	}
	@Column(name = "stb_user_id")
	public Long getUserid() {
		return userid;
	}

	public void setUserid(Long userid) {
		this.userid = userid;
	}
	@ManyToOne(cascade = CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinColumn(name = "area_id", referencedColumnName = "area_id",nullable=false)
	public PMEArea getArea() {
		return area;
	}

	public void setArea(PMEArea area) {
		this.area = area;
	}
	@ManyToMany(cascade = CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinTable(name = "pme_basis_stb_camera", joinColumns = @JoinColumn(name = "stb_id") , inverseJoinColumns = @JoinColumn(name = "camera_id") )
	public Set<PMECamera> getCameras() {
		return cameras;
	}

	public void setCameras(Set<PMECamera> cameras) {
		this.cameras = cameras;
	}
	@ManyToMany(cascade = CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinTable(name = "pme_basis_stb_duties", joinColumns = @JoinColumn(name = "stb_id") , inverseJoinColumns = @JoinColumn(name = "duties_id") )
	public Set<PMEDuties> getDuties() {
		return duties;
	}

	public void setDuties(Set<PMEDuties> duties) {
		this.duties = duties;
	}
	@Column(name = "camera_id")
	public Long getCameraid() {
		return cameraid;
	}

	public void setCameraid(Long cameraid) {
		this.cameraid = cameraid;
	}
	@OneToMany(mappedBy = "stb", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	public Set<PMETopic> getTopics() {
		return topics;
	}

	public void setTopics(Set<PMETopic> topics) {
		this.topics = topics;
	}
	
}
